//
//  FunRectView.m
//  groupProject
//
//  Created by mac on 15/12/18.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "FunRectView.h"

@implementation FunRectView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype) initWithFrame:(CGRect)frame andImage:(NSString *) imagename andTitle:(NSString *)title {
    self = [super initWithFrame: frame];
    CGFloat imageWidth = frame.size.height * 0.5;
    if (self) {
        self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, frame.size.height * 0.7, frame.size.width, frame.size.height*0.2)];
        //self.label.text = title;
        self.label.textAlignment = NSTextAlignmentCenter;
        
        self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width/2.0 - imageWidth/2.0 , frame.size.width * 0.1, imageWidth, imageWidth)];
        self.imageView.image = [UIImage imageNamed:imagename];
        
    }
    // 画圆
        self.imageView.layer.cornerRadius = imageWidth/2.0;
        [self.imageView clipsToBounds];
    // label设置字体
    self.label.attributedText = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName:[UIColor grayColor], NSFontAttributeName:[UIFont systemFontOfSize:11]}];
    
    [self addSubview:self.imageView];
    [self addSubview:self.label];
    return self;
}

@end
